import React from 'react';
import { Empty } from 'antd';
import { withReducers } from '../../../colyst/store/StoreUtil';
import NextReducer from '../../../colyst/store/reducer/NextReducer';
import LandService from '../../../colyst/services/LandService';
import { getIntl } from '../../../colyst/util/AppUtil';
import BaseTable from '../../../colyst/component/common/table/BaseTable';

class Orders extends React.Component {

    state = {
        count: 1,
        ss: 2
    }

    test(num) {
        NextReducer.actions.setValue({next: 99, otherFn: 'aa'})
        // this.props.auths()
        // console.log(getState(NextReducer))
        // console.log(store.getState())
        // console.log(this.props)
        this.setState({ count: 2, ss: 2 })
        // console.log(!!count, num)
        // count = num
    }

    aaaaa = () => {
        console.log(111);
        
    }

    componentDidMount() {
        // console.log(NextReducer.actions.setValue)
        // console.log(store)
    }

    render() {
        let {next} = this.props;
        const columns = [
            { title: 'AAAAAA', dataIndex: 'key', width: 200,
                render: (text, row, index) => {
                    return(
                        <span onClick={() => this.aaaaa()}>text:{text} index:{index} row:{JSON.stringify(row)}</span>
                    )
                }
            },
            { title: 'B', dataIndex: 'key1', width: 200 },
            { title: 'C', dataIndex: 'key2', width: 500 },
            { title: 'D', dataIndex: 'key3', width: 200 },
            { title: 'F', dataIndex: 'key4'},
        ];
        
        const data = Array.from({ length: 1000 }, (_, key) => ({ key: key, key1: key + 1, key2: key + 2, key3: key + 3, key4: key + 4 }));
        
        return (
            <div>
                <button onClick={() => this.test(2)}>
                    Orders: {next}
                    {/* {getIntl().formatMessage('add')} */}
                </button>
                <button onClick={() => LandService.change('en')}>
                    changeEn
                    {/* {getIntl().formatMessage('add')} */}
                </button>
                <button onClick={() => LandService.change('zh')}>
                    changeZh
                    {/* {getIntl().formatMessage('add')} */}
                </button>
                <div>{getIntl().formatMessage({id: 'add'})}</div>
                <Empty />
                <div style={{width: '1200px', border: '1px solid #000'}}>
                    <BaseTable
                        columns={columns}
                        dataSource={data}
                        autoHeight={80}
                        rowSelection={{
                            type: 'checkbox',
                            // ...rowSelection,
                        }}
                        tableType = {'list'}
                        // scroll = {{ y: 300, x: '100vw' }}
                    />
                </div>
            </div>
        )
    }
}

// const mapStateToProps = (state: any) => ({
//     auth: state[RootReducer.key].auth
// });


// export default connect(mapStateToProps, null)(Orders)
export default withReducers(Orders, NextReducer)
// export default Orders